package com.nebrija.riif.parser;

import org.antlr.runtime.tree.Tree;

import com.nebrija.riif.model.Timeline;
import com.nebrija.riif.model.RIIFElement;
import com.nebrija.riif.model.RootClass;

/**
 * Processor which converts an environment token from the tree into an Environment object
 * @author asanchep
 *
 */
public class TimelineProcessor implements RIIFParserProcessor {

	@Override
	public RIIFElement apply(RIIFElement container, Tree t) {
		if(! (container instanceof RootClass)){
			return null;
		}
		// Get the id, create the environment and add it ot the RootClass
		String id = t.getChild(0).getText();
		Timeline tl = new Timeline(id);
		((RootClass)container).addElement(tl);
		return tl;
	}

}
